package com.jmes.web.listener;

import com.jmes.web.dao.DaoManager;
import com.jmes.web.dao.FunctionCodeTableMapper;
import com.jmes.web.model.FunctionCodeTable;
import com.jmes.web.model.FunctionCodeTableExample;
import com.jmes.web.service.RoleService;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.List;

/**
 * 系统初始化.
 * User: jinshunlong
 * Date: 13-4-14
 * Time: 下午7:40
 */
public class SetupListener implements ServletContextListener {
    private static Logger logger = Logger.getLogger(SetupListener.class);

    /**
     * Notification that the web application initialization
     * process is starting.
     * All ServletContextListeners are notified of context
     * initialisation before any filter or servlet in the web
     * application is initialized.
     */
    @Override
    public void contextInitialized(ServletContextEvent sce) {

        logger.info("=====Setup System=====");
        RoleService.setupFunctions();
        logger.info("=====Setup OK!!=====");
    }

    /**
     * Notification that the servlet context is about to be shut down. All servlets
     * have been destroy()ed before any ServletContextListeners are notified of context
     * destruction.
     */
    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
